24 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
25 #define For(i, a, b) for (int i=(a); i<(b); ++i)
26 #define D(x) cout << #x " is " << x << endl
28 const double EPS
= 1e-9;
29 int cmp(double x
, double y
= 0, double tol
= EPS
) {
30 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
35 point(double x
, double y
) : x(x
), y(y
) {}
37 bool operator < (const point
&p
) const {
38 int t
= cmp(this->x
, p
.x
);
39 if (t
!= 0) return t
< 0;
40 return cmp(this->y
, p
.y
) < 0;
42 bool operator == (const point
&p
) const {
43 return cmp(this->x
, p
.x
) == 0 and cmp(this->y
, p
.y
) == 0;
47 point
center(const point
&p
, const point
&q
, const point
&r
) {
48 double ax
= q
.x
- p
.x
;
49 double ay
= q
.y
- p
.y
;
50 double bx
= r
.x
- p
.x
;
51 double by
= r
.y
- p
.y
;
52 double d
= ax
*by
- bx
*ay
;
55 printf("Points are collinear!\n");
59 double cx
= (q
.x
+ p
.x
) / 2;
60 double cy
= (q
.y
+ p
.y
) / 2;
61 double dx
= (r
.x
+ p
.x
) / 2;
62 double dy
= (r
.y
+ p
.y
) / 2;
64 double t1
= bx
*dx
+ by
*dy
;
65 double t2
= ax
*cx
+ ay
*cy
;
67 double x
= (by
*t2
- ay
*t1
) / d
;
68 double y
= (ax
*t1
- bx
*t2
) / d
;
78 while (scanf("%d", &n
) == 1) {
81 for (int i
= 0; i
< n
; ++i
) {
82 scanf("%lf %lf", &points
[i
].x
, &points
[i
].y
);
91 for (int i
= 0; i
< n
; ++i
) {
92 for (int j
= i
+ 1; j
< n
; ++j
) {
94 for (int k
= 0; k
< n
; ++k
) {
95 if (k
== i
or k
== j
) continue;
96 double x0
= points
[i
].x
- points
[k
].x
;
97 double y0
= points
[i
].y
- points
[k
].y
;
98 double x1
= points
[j
].x
- points
[k
].x
;
99 double y1
= points
[j
].y
- points
[k
].y
;
100 if ( cmp(x0
*y1
- y0
*x1
, 0) == 0 ) continue; // collinear
101 centers
[last
++] = center(points
[i
], points
[j
], points
[k
]);
103 sort(centers
, centers
+ last
);
104 for (int k
= 0; k
< last
; ) {
106 while (same
< last
and centers
[k
] == centers
[same
]) same
++;
107 ans
= max(ans
, same
- k
+ 2);